package com.leadership.api.job;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.leadership.api.service.CourseLearningService;


/**
 * @author haiyan_xiao
 *
 */
@Component("courseLearningJob")
public class CourseLearningJob {

    private static final Logger logger = LoggerFactory.getLogger(CourseLearningJob.class);

    @Autowired
    private CourseLearningService courseLearningService;

    
    @Scheduled(cron = "30 0/10 * * * ? ")
    public void scanCourseLearningUpdate() {
        
        try {
            
            logger.info("#scanCourseLearningUpdate() - start at {}", new Date());
            
            courseLearningService.updateCourseLearning();
            
            logger.info("#scanCourseLearningUpdate() - finish at {}", new Date());
            
        } catch (Exception e) {
            logger.error("#scanCourseLearningUpdate() - occur exception=[{}]", e);
        }
        
    }
    
//    
//    @Scheduled(cron = "0 0/5 * * * ?")
//    public void scanUpdateCourseLearningStatus() {
//        try {
//            
//            logger.info("#scanUpdateCourseLearningStatus() - start at {}", new Date());
//            
//            courseLearningService.updateCourseLearningStatus();
//            
//            logger.info("#scanUpdateCourseLearningStatus() - finish at {}", new Date());
//            
//        } catch (Exception e) {
//            logger.error("#scanUpdateCourseLearningStatus() - occur exception=[{}]", e);
//        }
//    }
}
